home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 49 / 049.d81 / dec_hex converte (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  923b  |  32 lines

  1. 5 poke53280,.:poke53281,.
  2. 10 print"[147]        [154]decimal <--> hexidecimal"
  3. 20 print"        (d[154])ecimal to hex"
  4. 30 print"        (h[154])ex to decimal"
  5. 40 print"        (q[154])uit"
  6. 50 geta$:ifa$=""then50
  7. 60 ifa$="d"then140
  8. 70 ifa$="h"then210
  9. 80 ifa$="q"then60000
  10. 90 goto50
  11. 100 rem * dec-hex & hex-dec converters
  12. 110 rem * created by louis f. sander
  13. 120 :
  14. 130 rem dec-hex converter (0-65535)
  15. 140 input "dec numeral (0-65535)";d
  16. 150 rem next line does the conversion
  17. 160 h$="":d=d/4096:forj=1to4:d%=d:h$=h$+chr$(48+d%-(d%>9)*7):d=16*(d-d%):next
  18. 170 print "          hex numeral: [153]$";h$
  19. 175 print"        [154]press space [154]to continue"
  20. 176 ifpeek(203)<>60then176
  21. 180 run
  22. 190 :
  23. 200 rem hex-dec converter (0000-ffff)
  24. 210 input "    [154]4-digit hex numeral";h$
  25. 220 rem next line does the conversion
  26. 230 d=0:forj=1to4:d%=asc(h$):d%=d%-48+(d%>64)*7:h$=mid$(h$,2):d=16*d+d%:next
  27. 240 print "        dec numeral: ";d
  28. 250 goto175
  29. 60000 print"[147][144]load"chr$(34)"tips and tricks"chr$(34)",8"
  30. 60010 print"run"
  31. 60020 poke631,13:poke632,13:poke198,2:end
  32.